import request from '@/utils/request'

export function apply(data) {
  return request({
    url: 'api/insured-apply',
    method: 'post',
    data
  })
}

export function del(ids) {
  return request({
    url: 'api/insured-apply/',
    method: 'delete',
    data: ids
  })
}

export function edit(data) {
  return request({
    url: 'api/insured-apply',
    method: 'put',
    data
  })
}

export function detail(id) {
  return request({
    url: `/api/insured-apply/handler?id=${id}`,
    method: 'get'
  })
}

export function update(data) {
  return request({
    url: `/api/insured-apply/handler`,
    method: 'post',
    data
  })
}

export function loadUpdateData(id) {
  return request({
    url: 'api/insured-apply/update',
    params: { id: id }
  })
}

export function updateUser(data) {
  return request({
    url: `/api/insured-apply/user`,
    method: 'post',
    data
  })
}

export function getConnectTimes(next) {
  return request({
    url: `/api/insured-apply/exists-next-time`,
    method: 'get',
    params: { next }
  })
}

/**
 * 创建案件
 * @param {*} data
 * @returns
 */
export function userApply(data) {
  return request({
    url: '/api/insured/user-apply',
    method: 'post',
    data
  })
}

/**
 * 编辑案件
 * @param {*} data
 * @returns
 */
export function updateUserApply(data) {
  return request({
    url: '/api/insured/user-apply',
    method: 'put',
    data
  })
}

/**
 * 根据手机号码和时间戳匹配一个案件
 * @param {*} data
 * @returns
 */
export function userApplyMatching(params) {
  return request({
    url: '/api/insured/user-apply/matching',
    method: 'get',
    params
  })
}

/**
 * 补充资料
 * @param {*} data
 * @returns
 */
export function userApplyReplenish(data) {
  return request({
    url: '/api/insured/user-apply/replenish',
    method: 'post',
    data
  })
}

/**
 * 查看案件进度
 * @param {*} data
 * @returns
 */
export function userApplySpeed(params) {
  return request({
    url: '/api/insured/user-apply/speed',
    method: 'get',
    params
  })
}

export default {
  apply,
  edit,
  del,
  detail,
  update,
  loadUpdateData,
  updateUser,
  getConnectTimes,
  userApply,
  userApplyMatching,
  userApplyReplenish,
  userApplySpeed,
  updateUserApply
}
